<?php
/**
 *
 * @license http://www.gnu.org/licenses/gpl-3.0.txt
 * @encoding UTF-8
 *
 * Copyright (c) 2011 Charly Poly <charly.poly[at]live[dot]fr>
 * Copyright (c) 2011 <Prenom Nom> <email>
 * All rights reserved.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

/*
 * Utils
 */
/**
 * Permet de verifier la presence d'une variable $_POST pour les formulaires
 * @param string $index
 * @return bool
 */
function POST($index) {
    return (isset($_POST[$index]) && !empty ($_POST[$index]));
}
/**
 * Permet de proteger les données en affichage et dans le bon encodage
 * @param string $str
 * @return string
 */
function HTML($str) {
    return nl2br(htmlentities($str, ENT_QUOTES, "utf-8"));
}
/**
 * Transforme des format URL ( espaces par tiret bas ) en string exploitable pour SQL
 * @example "Charly_Poly" devient "Charly Poly"
 * @param string $str
 * @return string
 */
function URL2SQL($str) {
    return $str = str_replace("_", " ", $str);
}
/**
 * Transforme des format SQL  en format URL ( espaces par tiret bas )
 * @example "Charly Poly" devient "Charly_Poly"
 * @param string $str
 * @return string
 */
function SQL2URL($str) {
    return $str = str_replace(" ", "_", $str);
}
/*
 * Aliases
 */

function S() {
    return Storage::getInstance();
}

function L() {
    return Session::getInstance()->getLang();
}
?>
